package com.eric.es.document;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;

@Document(indexName = "demo-log")
@ToString
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LogEntity {

    @Id
    private String id;

    /**
     * 日志等级
     */
    @Field(type = FieldType.Keyword)
    private String level;

    /**
     * 日志标题
     */
    @Field(type = FieldType.Text)
    private String title;

    /**
     * 日志内容
     */
    @Field(type = FieldType.Text)
    private String content;

    /**
     * 记录时间
     *
     * 注意时间类的使用
     *
     *
     *     对应 ==> LocalDate
     *     date("uuuu-MM-dd")
     *
     *     对应 ==> LocalDateTime
     *     date_hour("uuuu-MM-dd'T'HH")
     *     date_hour_minute("uuuu-MM-dd'T'HH:mm")
     *     date_hour_minute_second("uuuu-MM-dd'T'HH:mm:ss")
     *
     *     对应 ==> LocalTime
     *     hour("HH")
     *     hour_minute("HH:mm")
     *     hour_minute_second("HH:mm:ss")
     *     hour_minute_second_fraction("HH:mm:ss.SSS")
     *     hour_minute_second_millis("HH:mm:ss.SSS")
     */
    @Field(type = FieldType.Date,format = DateFormat.date)
    private LocalDate recordTime;



}